{% extends 'base.html' %}
{% block content %}
<div class="column col-10 col-mx-auto" style="padding-top: 100px">
    {% for question in question_list %}
    <div class="card" style="margin-top: 15px">
        <div class="card-body">
            <div class="column col-12 col-xs-12">
                <div class="tile">
                    <div class="tile-icon">
                        <figure class="avatar avatar-lg">
                            <img src="{{url_for('static', filename='img/avatar.png')}}" alt="Avatar">
                        </figure>
                    </div>
                    <div class="tile-content">
                        <p class="tile-title">{{ question.author }}</p>
                        <p class="tile-subtitle"><a href="/question/{{ question.question_id }}">{{ question.title }}</a></p>
                    </div>
                    <span style="color: #0b4780;font-size: small;">{{ question.timestamp }}</span>
                </div>
            </div>
        </div>
        <div class="card-footer">
            {% if session.user %}
            <button class="btn btn-success" doc_type="question" doc_id="{{question.question_id}}" name="vote" direction="vote_up">
                <i class="icon icon-arrow-up"></i>&nbsp;赞同&nbsp;{{question.vote_up}}
            </button>
            <button class="btn btn-action btn-error circle" doc_type="question" doc_id="{{question.question_id}}" name="vote" direction="vote_down">
                <i class="icon icon-arrow-down"></i>
            </button>
            {% else %}
            <button class="btn btn-success disabled" doc_type="question" doc_id="{{question.question_id}}" name="vote" direction="vote_up">
                <i class="icon icon-arrow-up"></i>赞同{{question.vote_up}}
            </button>
            <button class="btn btn-action btn-success circle disabled" doc_type="question" doc_id="{{question.question_id}}" name="vote" direction="vote_down">
                <i class="icon icon-arrow-down"></i>
            </button>
            {% endif %}
            <button class="btn btn-link"><a href="/question/{{question.question_id}}">回答({{question.answer_number}})</a></button>
        </div>
    </div>
    {% endfor %}
    <div class="column col-md-4 col-mx-auto">
        <ul class="pagination">
            {% if current_page > 1 %}
                <li class="page-item">
            {% else %}
                <li class="page-item disabled">
            {% endif %}
                    <a href="/page/{{ current_page - 1 }}" tabindex="-1">上一页</a>
                </li>
            {% for page in page_list %}
                {% if page == current_page %}
                    <li class="page-item disabled">
                        <a href="/page/{{ page }}">{{ page }}</a>
                {% else %}
                    <li class="page-item">
                        <a href="/page/{{ page }}">{{ page }}</a>
                {% endif %}
                    </li>
            {% endfor %}
            {% if page_list and current_page >= page_list[-1] %}
                <li class="page-item disabled">
            {% else %}
                <li class="page-item">
            {% endif %}
                    <a href="/page/{{ current_page + 1 }}">下一页</a>
                </li>
        </ul>
    </div>
</div>
{% endblock %}